#include <heap.h>

extern int end;
int placement_address = (int)&end;

int kmalloc_int(int size, int align, int *addr_phys)
{
	if (align==1 && (placement_address & 0xFFFFF000))
	{
		placement_address&=0xFFFFF000;
		placement_address+=0x1000;
	}
	if (addr_phys)
	{
		*addr_phys=placement_address;
	}
	int tmp = placement_address;
	placement_address+=size;
	return tmp;	
}

int kmalloc(int size)
{
	return kmalloc_int(size,0,0);
}

int kmalloc_a(int size)
{
	return kmalloc_int(size,1,0);
}

extern int kmalloc_ap(int size, int *phys)
{
	return kmalloc_int(size,1,phys);
}